package com.xdh.zzqh.ui.view

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.Button
import android.widget.FrameLayout
import com.xdh.zzqh.R

import com.xdh.zzqh.utils.onClick
import com.xdh.zzqh.utils.showToast

class InputOrderParts(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) {

    private val input: LabelTextInput

    init {
        val view = LayoutInflater.from(context).inflate(R.layout.parts_input_order, this)

        input = view.findViewById(R.id.id_order_lti_type)
        val btnSelect = view.findViewById<Button>(R.id.id_order_btn_select)
        val btnSave = view.findViewById<Button>(R.id.id_order_btn_save)
        val btnDelete = view.findViewById<Button>(R.id.id_order_btn_delete)

        val attr = context.obtainStyledAttributes(attrs, R.styleable.InputOrderParts)

        val index = attr.getInteger(R.styleable.InputOrderParts_order_index, 0)
        val name = attr.getString(R.styleable.InputOrderParts_order_name) ?: ""
        val def = attr.getString(R.styleable.InputOrderParts_order_def) ?: ""

        input.setName(name)
        input.setText(def)

        attr.recycle()


        btnSelect.onClick {


        }


        btnSave.onClick {

        }

        btnDelete.onClick {

        }
    }

    fun text(): String {
        return input.text()
    }
}

